//
//  AFHTTPSessionManager+Shared.m
//  NongWanCloud
//
//  Created by YueWen on 2018/1/3.
//  Copyright © 2018年 YueWen. All rights reserved.
//

#import "AFHTTPSessionManager+Shared.h"

@implementation AFHTTPSessionManager (Shared)

+(instancetype)sharedInstance
{
    static AFHTTPSessionManager *manager = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        manager = [AFHTTPSessionManager manager];
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        
//        AFJSONRequestSerializer *jsonRequestSerializer = [AFJSONRequestSerializer serializer];
//        [jsonRequestSerializer setValue:@"iOS" forHTTPHeaderField:@"X_Requested_With"];
        manager.requestSerializer = [AFHTTPRequestSerializer serializer];
        [manager.requestSerializer setValue:@"iOS" forHTTPHeaderField:@"X_Requested_With"];
//        manager.requestSerializer = jsonRequestSerializer;
        manager.requestSerializer.timeoutInterval = 5;
        
        //支持Https
        AFSecurityPolicy *securityPolicy = [AFSecurityPolicy defaultPolicy];
        securityPolicy.allowInvalidCertificates = true;
        securityPolicy.validatesDomainName = false;
        manager.securityPolicy = securityPolicy;
        
    });
    
    return manager;
}


-(instancetype)timeOut:(NSTimeInterval)outTime
{
    self.requestSerializer.timeoutInterval = outTime;
    
    return self;
}

@end
